/**
 * 
 */
package org.gaming.prefab.thing.reward;

import java.util.ArrayList;
import java.util.List;

/**
 * @author YY
 *
 */
public class RewardReceipt<Num extends Number> {

	public static final RewardReceipt<?> EMPTY = new RewardReceipt<>();
	
	private final List<RewardDetail> details = new ArrayList<>();
	//备注
	private String remark = "";
	
	public RewardReceipt() {}
	
	public RewardReceipt(List<? extends IRewardThing<Num>> rewardThings) {
		for(IRewardThing<Num> thing : rewardThings) {
			RewardDetail detail = new RewardDetail(thing.getThingId(), thing.getNumber());
			details.add(detail);
		}
	}
	
	public RewardReceipt<Num> append(int thingId, Num num, Object extra) {
		RewardDetail detail = new RewardDetail(thingId, num, extra);
		details.add(detail);
		return this;
	}
	
	public void merge(RewardReceipt<Num> rewardReceipt) {
		this.details.addAll(rewardReceipt.details);
	}
	
	public List<RewardDetail> getDetails() {
		return details;
	}
	
	public class RewardDetail {
		private int thingId;
		private Num num;
		private Object extra;
		
		public RewardDetail(int thingId, Num num, Object extra) {
			this.thingId = thingId;
			this.num = num;
			this.extra = extra;
		}
		public RewardDetail(int thingId, Num num) {
			this(thingId, num, null);
		}
		
		public int getThingId() {
			return thingId;
		}
		public Num getNum() {
			return num;
		}
		public Object getExtra() {
			return extra;
		}
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}
